//
//  UIChangeDiffentStyle.m
//  EducationAdminClient
//
//  Created by kwsdzjx on 16/9/26.
//  Copyright © 2016年 周佳兴. All rights reserved.
//

#import "UIChangeDiffentStyle.h"
#define STYLE0 @"0" // 主项目风格
#define STYLE1 @"1" // 学员端风格

@implementation UIChangeDiffentStyle
-(id)UIStyle:(NSString *)style andCollectionView:(UICollectionView *)collectionView withIndexPath:(NSIndexPath *)indexPath andModel:(ThingsModel *)model{
    if ([style isEqualToString:STYLE0]) {
        return [self style0Model:model andCollectionView:collectionView withIndexPath:indexPath];
    }else{
        return [self style1Model:model andCollectionView:collectionView withIndexPath:indexPath];
    }
}

/**
 *学员端风格 cell
 */
-(FounctionCollectionCell *)style1Model:(ThingsModel *)model andCollectionView:(UICollectionView *)collectionView withIndexPath:(NSIndexPath *)indexPath{

    static NSString * CellIdentifier = @"UICollectionViewCell";
    FounctionCollectionCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    
    cell.titleLa.text = @"";
    cell.titleImg.image = [UIImage imageNamed:[NSString stringWithFormat:@""]];
    
    NSDictionary *valueMap = [model.valueMap firstObject];
    if(model.cnName){
        
        NSMutableString *strMenuName = [NSMutableString stringWithFormat:@"%@", model.cnName];
        
        if ([strMenuName rangeOfString:@"手机端"].location != NSNotFound) {
            [strMenuName replaceCharactersInRange:[strMenuName rangeOfString:@"手机端"] withString:@""];
        }
        
        cell.titleLa.text = strMenuName;
        int x = arc4random() % 4;
        
        cell.titleImg.image = [UIImage imageNamed:[NSString stringWithFormat:@"Student_00%i", x+1]];
        
        NSNumber *value = [valueMap objectForKey:@"name"];
        NSInteger intForValue = value.integerValue;
        cell.NumberLa.text = [NSString stringWithFormat:@"%zd个",intForValue];
        //         = [UIImage imageNamed:@"形状-9"];
        [cell changeRect:NO];
        
    }else{
        [cell changeRect:YES];

    }
    
    [cell changeLine:indexPath];
    
    
    
    
    return cell;
    
}

/**
 * 教师端风格
 */
-(FounctionCollectionCell *)style0Model:(ThingsModel *)model andCollectionView:(UICollectionView *)collectionView withIndexPath:(NSIndexPath *)indexPath{
    
    
    
    static NSString * CellIdentifier = @"UICollectionViewCell";
    FounctionCollectionCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    
    cell.titleLa.text = @"";
    cell.titleImg.image = [UIImage imageNamed:[NSString stringWithFormat:@""]];

    NSDictionary *valueMap = [model.valueMap firstObject];
    if(model.cnName){
        
        
        NSMutableString *strMenuName = [NSMutableString stringWithFormat:@"%@", model.cnName];
        
        if ([strMenuName rangeOfString:@"手机端"].location != NSNotFound) {
            [strMenuName replaceCharactersInRange:[strMenuName rangeOfString:@"手机端"] withString:@""];
        }
        
        cell.titleLa.text = strMenuName;
        int x = arc4random() % 4;
        
        cell.titleImg.image = [UIImage imageNamed:[NSString stringWithFormat:@"Student_00%i", x+1]];
        NSNumber *value;
        if (valueMap == [NSNull null]) {
            value = [NSNumber numberWithInteger:0];
        }else{
            value = [valueMap objectForKey:@"name"];
        }
        
        
        NSInteger intForValue = value.integerValue;
        cell.NumberLa.text = [NSString stringWithFormat:@"%zd个",intForValue];
        
        [cell changeRect:NO];
        
    }else{
        [cell changeRect:YES];
    }
    
    [cell changeLine:indexPath];
    
    
    
    
    
    
    return cell;
}
@end
